<template>
    <div>
        <div class="header_search"  v-show="!showPhotoPage">
            <a-row>
                <a-col span="6" v-if="!showAllFlag">
                    <a-icon type="left-circle" theme="filled"  style="font-size: 30px; color: #48D3A4;"  @click="backMain"/>
                </a-col>
                <a-col span="6" v-else>
                    <a-icon type="left-circle" theme="filled"  style="font-size: 30px; color: #48D3A4;"  @click="backFruit"/>
                </a-col>
                <a-col span="12">
                      <a-input-search v-model="searchContent"
                                      size="large"
                                      @search="onSearch">
                      </a-input-search>
<!--                  <a-input-search placeholder="" v-model="searchContent" @search="onSearch" allowClear>-->
<!--                        <a-select slot="addonBefore" :key="selectedType" :default-value="selectedType" style="width: 120px; font-size: 18px; border-radius: 0 0 50px 50px; padding-left: 5px;" @change="handleChange" >-->
<!--                            <a-select-option value="0">-->
<!--                                综合检索-->
<!--                            </a-select-option>-->
<!--                            <a-select-option value="1">-->
<!--                                主题-->
<!--                            </a-select-option>-->
<!--                            <a-select-option value="2">-->
<!--                                作者-->
<!--                            </a-select-option>-->
<!--                            &lt;!&ndash;              <a-select-option value="3">&ndash;&gt;-->
<!--                            &lt;!&ndash;                领域&ndash;&gt;-->
<!--                            &lt;!&ndash;              </a-select-option>&ndash;&gt;-->
<!--                        </a-select>-->
<!--                    </a-input-search>-->
                </a-col>
                <a-col span="6">
                    <div style="line-height: 45px;">
                <span style="line-height: 20px; vertical-align: bottom; font-size: 16px; padding-left: 30px; cursor: pointer;" @click="advancedSearch">
                    <span style="text-decoration: underline;">高级检索</span>&nbsp;
                    <span v-if="showAllFlag">▲</span>
                    <span v-if="!showAllFlag">▼</span>
                </span>
                    </div>
                </a-col>
            </a-row>
            <br/>
            <div v-if="!showAllFlag">
                <a-row>
                    <a-col span="6">
                        <a-card style="width: 80%; margin: auto; border-radius: 10px; background: linear-gradient(134.97deg, rgba(239,250,251,1) 0.1%,rgba(147,227,201,0.3) 98.05%);" size="small">
                            <a slot="title" href="#" class="cardTit"><a-icon type="calendar" />&nbsp;&nbsp;&nbsp;日期</a>
                            <a slot="extra" href="#"><a-icon type="down" /></a>
                            <a-range-picker style="width: 100%" @change="dataChange" format="YYYY-MM-DD" :value="rangeValue"/>
                            <a-row style="margin-top: 10px;">
                                <a-col span="8" style="text-align: left;">
                                    <a-button type="primary" :ghost="selectedBtnType != 3" class="dateBtn" @click="setDateType(3)">近三年</a-button>
                                </a-col>
                                <a-col span="8" style="text-align: center;">
                                    <a-button type="primary" :ghost="selectedBtnType != 5" class="dateBtn" @click="setDateType(5)">近五年</a-button>
                                </a-col>
                                <a-col span="8" style="text-align: right;">
                                    <a-button type="primary" :ghost="selectedBtnType != 10" class="dateBtn" @click="setDateType(10)">近十年</a-button>
                                </a-col>
                            </a-row>
                        </a-card>
                        <br/>
                        <a-card style="width: 80%; margin: auto; border-radius: 10px; background: linear-gradient(134.97deg, rgba(239,250,251,1) 0.1%,rgba(147,227,201,0.3) 98.05%);" size="small">
                            <a slot="title" href="#" class="cardTit"><a-icon type="search" />&nbsp;&nbsp;&nbsp;研究领域</a>
                            <a slot="extra" href="#"><a-icon type="down" /></a>
                            <a-spin tip="数据加载中..." v-if="!isHaveDataFields">
                                <div class="spin-content">
                                </div>
                            </a-spin>
                            <div v-if="isHaveDataFields">
                                <div v-if="showFields.length > 0">
                                    <a-checkbox-group @change="onChangeField" :value="searchObj.fieldNames">
                                        <a-row v-for="item in showFields">
                                            <a-col :span="24">
                                                <a-checkbox :value="item.name">
                                                    <span style="font-size: 15px; line-height: 30px;">{{ item.name }}</span>
<!--                                                    <span style="font-size: 15px; line-height: 30px;">{{ item.name }}（{{item.count}}）</span>-->
                                                </a-checkbox>
                                            </a-col>
                                        </a-row>
                                    </a-checkbox-group>
                                    <!--                    <div style="text-align: center; font-size: 15px; cursor: pointer;" v-if="researchFieldsTotal > fieldsNum" @click="showMoreFieldsData">加载更多<a-spin v-if="!showMoreFieldsLoading"/>....</div>-->
                                </div>
                                <div v-else>
                                    <a-empty />
                                </div>
                            </div>
                        </a-card>
                        <!--            <br/>-->
                        <!--            <a-card style="width: 80%; margin: auto; border-radius: 10px; background: linear-gradient(134.97deg, rgba(239,250,251,1) 0.1%,rgba(147,227,201,0.3) 98.05%);" size="small">-->
                        <!--              <a slot="title" href="#" class="cardTit"><a-icon type="bank" />&nbsp;&nbsp;&nbsp;合作部门</a>-->
                        <!--              <a slot="extra" href="#"><a-icon type="down" /></a>-->
                        <!--              <a-spin tip="数据加载中..." v-if="!isHaveDataDepts">-->
                        <!--                <div class="spin-content">-->
                        <!--                </div>-->
                        <!--              </a-spin>-->
                        <!--              <div v-if="isHaveDataDepts">-->
                        <!--                <div v-if="showDepts.length > 0">-->
                        <!--                  <a-checkbox-group @change="onChangeDept" :value="searchObj.orgNames">-->
                        <!--                    <a-row v-for="item in showDepts">-->
                        <!--                      <a-col :span="24">-->
                        <!--                        <a-checkbox :value="item.name">-->
                        <!--                          <span style="font-size: 15px; line-height: 30px;">{{ item.name }}（{{item.count}}）</span>-->
                        <!--                        </a-checkbox>-->
                        <!--                      </a-col>-->
                        <!--                    </a-row>-->
                        <!--                  </a-checkbox-group>-->
                        <!--                    <div style="text-align: center; font-size: 15px; cursor: pointer;"  v-if="cooperationDeptsTotal > deptsNum" @click="showMoreDeptsData">加载更多<a-spin v-if="!showMoreDeptsLoading"/>....</div>-->
                        <!--                </div>-->
                        <!--                <div v-else>-->
                        <!--                  <a-empty />-->
                        <!--                </div>-->
                        <!--              </div>-->
                        <!--            </a-card>-->
                    </a-col>
                    <a-col span="18">
                        <a-card style="border-radius: 10px;">
                            <a-row :gutter="16">
                                <a-col span="10">
                                    <a-spin tip="数据加载中..." v-if="!isHaveDataTalent">
                                        <div class="spin-content">
                                        </div>
                                    </a-spin>
                                    <div v-if="isHaveDataTalent">
                                        <div style="line-height: 30px; padding: 5px;">
                                            <a-row>
                                                <a-col span="16">
                                                    <div style="font-weight: bolder; color: rgba(3, 129, 129, 1); font-size: 20px;">推荐专家</div>
                                                </a-col>
                                                <a-col span="8" v-if="talentInfoList.records.length > 0">
                                                    <div style="font-weight: bolder; color: rgba(3, 129, 129, 1); font-size: 14px; text-align: right; cursor: pointer;" @click="changeNew" >换一批&nbsp;&nbsp;&nbsp;<a-icon type="sync" :spin="refreshLoading"/></div>
                                                </a-col>
                                            </a-row>
                                        </div>
                                        <div v-if="talentInfoList.records.length > 0" style="padding-top: 15px;">
                                            <div v-for="item in talentInfoList.records" style="margin-top: 5px;">
                                                <a-card style="border-radius: 10px; margin: auto; cursor: pointer; background: linear-gradient(89.83deg, rgba(255,255,255,1) 1.05%,rgba(147,227,201,1) 82.48%,rgba(84,211,170,1) 100.35%);" size="small"
                                                        :class="selectedOrgUserId == item.authorId ? 'bordc' : ''"
                                                        @click="changFruitData(item.authorId, item.authorName, true)">
                                                    <a-row>
                                                        <a-col span="6">
                                                            <a-avatar shape="square" :size="100" :src="!!item.photo ? item.photo : photo" />
                                                        </a-col>
                                                        <a-col span="18">
                                                            <div style="padding-left: 5px;">
                                                                <a-row>
                                                                    <a-col span="8" style="color: rgba(3, 129, 129, 1); font-size: 28px; cursor: pointer; line-height: 30px; font-weight: bold;">
                                                                        {{item.authorName}}
                                                                    </a-col>
                                                                    <a-col span="16" style="padding-top: 10px;font-weight: bold; text-align: right">
                                                                        <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{item.company}}</div>
                                                                    </a-col>
                                                                </a-row>
                                                                <a-row>
                                                                    <a-col span="8" style="padding-top: 10px;font-weight: bold;">
                                                                        <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{item.phoneNumber}}</div>
                                                                    </a-col>
<!--                                                                    <a-col span="16" style="padding-top: 10px;font-weight: bold; text-align: right" v-if="item.cooperationNum">合作次数：{{item.cooperationNum}}次</a-col>-->
                                                                </a-row>
                                                                <a-row>
                                                                    <a-col span="24" style="line-height: 40px; font-size: 13px; font-weight: bold; color: #FD8024; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
                                                                           :title="item.fieldNames">
                                                                        {{item.fieldNames}}
                                                                    </a-col>
                                                                </a-row>
                                                            </div>
                                                        </a-col>
                                                    </a-row>
                                                </a-card>
                                            </div>
<!--                                            <div style="text-align: center; font-size: 15px; padding-top: 15px; font-weight: bold; cursor: pointer;"-->
<!--                                                 v-if="talentInfoList.total > 10"-->
<!--                                                 @click="showAllTalentInfo(1)">查看全部....</div>-->
                                        </div>
                                        <div v-else>
                                            <a-empty>
                                                <template #description>
                              <span>
                                暂无跟您相关领域的专家推荐
                              </span>
                                                </template>
                                            </a-empty><br/>
<!--                                            <a-divider orientation="left">为您推荐了其他领域的相关专家</a-divider>-->
<!--                                            <div v-if="isHaveOtherDataTalent">-->
<!--                                                <div v-if="otherTalentInfoList.records.length > 0" style="padding-top: 15px;">-->
<!--                                                    <div v-for="item in otherTalentInfoList.records" style="margin-top: 5px;">-->
<!--                                                        <a-card style="border-radius: 10px; margin: auto; cursor: pointer; background: linear-gradient(89.83deg, rgba(255,255,255,1) 1.05%,rgba(147,227,201,1) 82.48%,rgba(84,211,170,1) 100.35%);" size="small"-->
<!--                                                                :class="selectedOrgUserId == item.authorId ? 'bordc' : ''"-->
<!--                                                                @click="changFruitData(item.authorId, item.authorName, false)">-->
<!--                                                            <a-row>-->
<!--                                                                <a-col span="6">-->
<!--                                                                    <a-avatar shape="square" :size="100" :src="photo" />-->
<!--                                                                </a-col>-->
<!--                                                                <a-col span="18">-->
<!--                                                                    <div style="padding-left: 5px;">-->
<!--                                                                        <a-row>-->
<!--                                                                            <a-col span="8" style="color: rgba(3, 129, 129, 1); font-size: 28px; cursor: pointer; line-height: 30px; font-weight: bold;">-->
<!--                                                                                {{item.authorName}}-->
<!--                                                                            </a-col>-->
<!--                                                                            <a-col span="16" style="line-height: 30px; font-size: 18px; font-weight: bold; color: #FD8024; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"-->
<!--                                                                                   :title="item.field">-->
<!--                                                                                {{item.field}}-->
<!--                                                                            </a-col>-->
<!--                                                                        </a-row>-->
<!--                                                                        <a-row>-->
<!--                                                                            <a-col span="6" style="padding-top: 10px;font-weight: bold;">-->
<!--                                                                                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{item.phoneNumber}}</div>-->
<!--                                                                            </a-col>-->
<!--                                                                            <a-col span="18" style="padding-top: 10px;font-weight: bold; text-align: right">-->
<!--                                                                                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{item.company}}</div>-->
<!--                                                                            </a-col>-->
<!--                                                                        </a-row>-->
<!--                                                                        <a-row>-->
<!--                                                                            <a-col span="24" style="padding-top: 10px;font-weight: bold;">合作次数：{{item.cooperationNum}}次</a-col>-->
<!--                                                                        </a-row>-->
<!--                                                                    </div>-->
<!--                                                                </a-col>-->
<!--                                                            </a-row>-->
<!--                                                        </a-card>-->
<!--                                                    </div>-->
<!--                                                    <div style="text-align: center; font-size: 15px; padding-top: 15px; font-weight: bold; cursor: pointer;"-->
<!--                                                         v-if="otherTalentInfoList.total > 10"-->
<!--                                                         @click="showAllTalentInfo(2)">查看全部....</div>-->
<!--                                                </div>-->
<!--                                            </div>-->
                                        </div>
                                    </div>
                                </a-col>
                                <a-col span="14">
                                    <a-card size="small" style="border-radius: 10px;">
                                        <a-spin tip="数据加载中..." v-if="!isHaveFruitData">
                                            <div class="spin-content">
                                            </div>
                                        </a-spin>
                                        <div v-if="isHaveFruitData">
                                          <div v-if="talentFruitList.records.length == 0">
                                            <div style="font-weight: bolder; color: rgba(3, 129, 129, 1); font-size: 20px;">
                                                <div style="line-height: 40px;">{{selectedAuthorName}}&nbsp;&nbsp;&nbsp;代表成果</div>
                                            </div>
                                          </div>
                                            <div v-if="talentFruitList.records.length > 0">
                                              <div style="font-weight: bolder; color: rgba(3, 129, 129, 1); font-size: 20px;">
                                                <div style="line-height: 40px; float: left;">{{selectedAuthorName}}&nbsp;&nbsp;&nbsp;代表成果</div>
                                              </div>
                                              <div>
                                                <a-button type="primary" style="margin: 5px 50px; border-radius: 50px;" @click="toInfo()">
                                                  查看专家画像
                                                </a-button>
                                              </div>
                                                <div style="border-top: 1px solid #c7c5c5; padding: 15px;" v-for="item in talentFruitList.records">
                                                    <a-row>
                                                        <a-col span="20">
                                                            <div class="ft" @click="showFruitInfo(item)">{{item.fruitName}}</div>
                                                        </a-col>
                                                        <a-col span="4">
                                                            <a-tag style="font-size: 15px; border-radius: 10px; color: #fff; padding: 5px 10px; background: linear-gradient(93.32deg, rgba(25,151,133,1) 2.78%,rgba(84,211,170,1) 97.62%)">
                                  <span>{{
                                          item.type == '3' ? '研究报告':
                                              item.type == '4' ? '活动成果':
                                                  item.type == '5' ? '媒体成果':
                                                      item.type == '6' ? '学术论文':
                                                          item.type == '7' ? '图书出版':
                                                              item.type == '8' ? '荣誉信息':
                                                                  item.type == '11' ? '专利成果':
                                                                      item.type == '12' ? '软著成果':  '其他成果'
                                      }}</span>
                                                            </a-tag>
                                                        </a-col>
                                                    </a-row>
                                                    <a-row style="margin-top: 5px;">
                                                        <a-col span="24">
                                                            <div v-for="tag in item.tags" style="display: inline-block; color: #189583; padding-right: 10px; font-size: 15px; font-weight: bold;">{{tag}}</div>
                                                        </a-col>
                                                    </a-row>
                                                    <a-row style="margin-top: 5px;">
                                                        <a-col span="20">
                                                            <div style="font-size: 15px; ">{{item.allAuthorName}}</div>
                                                            <div style="font-size: 15px;">{{item.orgName}}</div>
                                                        </a-col>
                                                        <a-col span="4">
                                                            <div style="font-size: 15px">{{item.pubTime != null ? item.pubTime.substring(0,10) : ""}}</div>
                                                        </a-col>
                                                    </a-row>
                                                </div>
                                                <div class="pagCs">
                                                    <a-pagination :current="currentPageNo" :total="parseInt(talentFruitList.total)" :show-total="total => `共 ${total} 条`" @change="onChangePage" />
                                                </div>
                                            </div>
                                            <div v-else>
                                                <a-card style="border-radius: 10px;">
                                                    <a-empty />
                                                </a-card>
                                            </div>
                                        </div>
                                    </a-card>
                                </a-col>
                            </a-row>
                        </a-card>
                    </a-col>
                </a-row>
            </div>
            <div v-else>
                <a-row :gutter="24">
                    <a-col span="4" style="color: rgba(0, 128, 128, 1); font-size: 25px; text-align: right;">专家姓名首字母</a-col>
                    <a-col span="20">
                        <div v-for="item in abcArr">
                            <div style="float: left; width: 40px; font-weight: bold; line-height: 35px; margin: 5px auto; cursor: pointer;"
                                 :class="selectedPinYin == item ? 'bigd' : 'def'"
                                 @click="changeTalentInfo(item)">
                                {{item}}
                            </div>
                        </div>
                    </a-col>
                </a-row>
                <a-row :gutter="24">
                    <a-col span="4" style="color: rgba(0, 128, 128, 1); font-size: 25px; text-align: right;">研究领域</a-col>
                    <a-col span="20">
                        <a-checkbox-group @change="onChangeGwField" :value="fieldCheckedList">
                            <a-row>
                                <a-col v-for="item in fieldsArr" :xs="24" :sm="12" :md="10" :lg="8" :xl="6">
                                    <a-checkbox :value="item">
                                        <span style="font-size: 15px; line-height: 30px;">{{ item }}</span>
                                    </a-checkbox>
                                </a-col>
                            </a-row>
                        </a-checkbox-group>
                    </a-col>
                </a-row>
<!--                <a-row :gutter="24">-->
<!--                    <a-col span="4" style="color: rgba(0, 128, 128, 1); font-size: 25px; text-align: right;">成果类型</a-col>-->
<!--                    <a-col span="20">-->
<!--                        <a-checkbox-group @change="onChangeGwFruitType" style="width: 100%;" :value="fruitTypeCheckedList">-->
<!--                            <a-row>-->
<!--                                <a-col :span="3" v-for="item in fruitTypeArr">-->
<!--                                    <a-checkbox :value="item.type">-->
<!--                                        <span style="font-size: 15px; line-height: 40px;">{{ item.name }}</span>-->
<!--                                    </a-checkbox>-->
<!--                                </a-col>-->
<!--                            </a-row>-->
<!--                        </a-checkbox-group>-->
<!--                    </a-col>-->
<!--                </a-row>-->
                <a-divider/>
                <div>
                    <a-spin tip="数据加载中..." v-if="!isHaveTalentInfoData">
                        <div class="spin-content">
                        </div>
                    </a-spin>
                    <div v-if="isHaveTalentInfoData">
                        <template v-if="talentAllInfoList.records.length > 0">
                            <a-row :gutter="24" style="min-height: 50px;">
                                <template v-for="item in talentAllInfoList.records">
                                    <a-col span="6">
                                        <a-card style="border-radius: 10px; cursor: pointer;margin-bottom: 10px;height: 130px; background: linear-gradient(89.83deg, rgba(255,255,255,1) 1.05%,rgba(147,227,201,1) 82.48%,rgba(84,211,170,1) 100.35%);" size="small"
                                                @click="toTalentInfo(item)">
                                            <a-row>
                                                <a-col span="10">
                                                    <a-avatar shape="square" :size="110" :src="photo" />
                                                </a-col>
                                                <a-col span="14">
                                                    <div style="padding-left: 5px;">
                                                        <a-row>
                                                            <a-col span="10" style="color: rgba(3, 129, 129, 1); font-size: 25px; cursor: pointer; line-height: 30px; font-weight: bold;">{{item.authorName}}</a-col>
                                                            <a-col span="14" style="line-height: 30px; font-size: 18px; font-weight: bold; color: #FD8024; text-align: right;">
                                                                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis" :title="item.field">{{item.field}}</div>
                                                            </a-col>
                                                        </a-row>
                                                        <a-row v-if="item.phoneNumber != null">
                                                            <a-col span="24" style="padding-top: 5px;font-weight: bold;">
                                                              <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis" :title="item.phoneNumber">{{item.phoneNumber}}</div>
                                                            </a-col>
                                                        </a-row>
                                                        <a-row v-if="item.company != null">
                                                            <a-col span="24" style="padding-top: 5px;font-weight: bold;">
                                                                  <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis" :title="item.company">{{item.company}}</div>
                                                            </a-col>
                                                        </a-row>
<!--                                                        <a-row v-if="item.cooperationNum != null">-->
<!--                                                            <a-col span="24" style="padding-top: 5px;font-weight: bold;">合作次数：{{item.cooperationNum}}次</a-col>-->
<!--                                                        </a-row>-->
                                                    </div>
                                                </a-col>
                                            </a-row>
                                        </a-card>
                                    </a-col>
                                </template>
                            </a-row>
                            <div class="pagCs">
                                <a-pagination :current="talentCurrentPageNo" :total="parseInt(talentAllInfoList.total)" :show-total="total => `共 ${total} 条`" @change="onChangeTalentPage" />
                            </div>
                        </template>
                        <div v-else>
                            <a-empty style="padding-top: 10%;"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <fruit-info ref="fruitInfo"></fruit-info>

        <talent-info  ref="childTalentInfo" @toShowPhotoPage="toShowPhotoPage" v-show="showPhotoPage"></talent-info>

        <div id="components-back-top-demo-custom">
            <a-back-top>
                <div class="ant-back-top-inner">
                    <a-icon type="up-circle" theme="filled" />
                </div>
            </a-back-top>
        </div>
    </div>
</template>

<script>

import fruitInfo from './FruitInfo.vue'
import talentInfo from './TalentInfo.vue'
import {postAction} from '../../api/manage'
import { getBeforeMonth, etCurrentDate, getMonthFirstDay, getMonthLastDay, getCurrentDate } from './dateTool'
import photo from './photo.png'

function removeDuplicates(inputString, chartSeq) {
    const charArray = inputString.split(chartSeq);
    const uniqueChars = [...new Set(charArray)];
    return uniqueChars.join(' ');
}

export default {
    name: 'TalentFruit',
    props: {
        // searchObj: {
        //   type: Object,
        //   default: () => {
        //     return {}
        //   }
        // }
    },
    components: {
        fruitInfo,
        talentInfo
    },
    data() {
        return {
            photo: photo,
            selectedType: "",
            searchContent: "",
            loading: false,
            otherloading: false,
            showPhotoPage: false,
            isHaveData: true,
            isHaveDataFields: true,
            showMoreFieldsLoading: true,
            isHaveDataDepts: true,
            showMoreDeptsLoading: true,
            isHaveDataTalent: true,
            isHaveOtherDataTalent: true,
            isHaveFruitData: true,
            searchObj:{
                current: 1,
                pageNo: 1,
                pageSize: 10
            },
            searchFieldObj:{
                current: 1,
                pageNo: 1,
                pageSize: 100
            },
            searchDeptObj:{
                current: 1,
                pageNo: 1,
                pageSize: 10
            },
            searchTalentFruitObj:{
                current: 1,
                pageNo: 1,
                pageSize: 10
            },
            selectedBtnType: "",
            rangeValue: [],
            currentPageNo: 1,
            researchFields: [],
            researchFieldsTotal: 0,
            cooperationDepts: [],
            cooperationDeptsTotal: 0,
            fieldNamesCount: {},
            showFields: [],
            showDepts: [],
            talentInfoList: {
                records: []
            },
            otherTalentInfoList: {
                records: []
            },
            talentFruitList: {
                records: []
            },
            selectedOrgUserId: "",
            selectedAuthorName: "",
            isContainField: true,
            refreshLoading: false,
            showAllFlag: false,
            talentAllInfoList: {
                records: []
            },
            abcArr:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],
            selectedPinYin: "",
            isHaveTalentInfoData: true,
            fieldsArr: ["碳达峰碳中和研究", "新型电力系统研究", "能源电力战略规划研究", "能源电力供需研究", "能源电力体制改革与电力市场研究", "能源电力数字经济研究",
                "企业战略规划研究", "企业经营与财务研究", "企业运营管理研究", "企业治理与风控合规研究", "品牌文化与社会责任研究", "数据、模型工具及实验室"],
            fieldCheckedList: [],
            fruitTypeArr: [{name: "学术论文", type: 6}, {name: "研究报告", type: 3}, {name: "活动成果", type: 4}, {name: "媒体成果", type: 5},
                {name: "图书出版", type: 7}, {name: "荣誉信息", type: 8}, {name: "专利成果", type: 11}, {name: "软著成果", type: 12}],
            // fruitTypeCheckedList: [3,4,5,6,7,8,11,12],
            fruitTypeCheckedList: [],
            searchTalentInfoObj: {
                current: 1,
                pageNo: 1,
                pageSize: 10
            },
            talentCurrentPageNo: 1,
            fieldsNum: 10,
            deptsNum: 10
        }
    },
    computed: {},
    created(){
    },
    methods: {
        handleChange(value) {
            console.log(`selected ${value}`);
            this.selectedType = value;
        },
        backMain(){
            this.searchObj = {
                current: 1,
                pageNo: 1,
                pageSize: 10
            };
            this.$emit('changeShow', true, false, false, this.searchObj);
        },
        toShowPhotoPage(flag){
            this.showPhotoPage = flag;
        },
        backFruit(){
            this.searchObj = {
                current: 1,
                pageNo: 1,
                pageSize: 10
            };
            this.showAllFlag = false;
        },
        showFruitInfo(item){
            this.$nextTick(()=>{
                this.$refs.fruitInfo.showModalInfo(item);
            })
        },
        toInfo(){
            this.showPhotoPage = true;
            this.$refs.childTalentInfo.showInfo(this.selectedOrgUserId, this.selectedAuthorName);
            // this.$emit('toTalentInfo', this.selectedOrgUserId, this.selectedAuthorName);
        },
        toTalentInfo(item){
            this.showPhotoPage = true;
            this.$refs.childTalentInfo.showInfo(item.authorId, item.authorName);
            // this.$emit('changeShow', false, false, true);
            // this.$emit('toTalentInfo', item.authorId, item.authorName);
        },
        addSearchContentLog(value){
            let url = "/ndTalent/operationLog/add";
            postAction(url, {content: value}).then(res => {
                if (res.data.success) {
                }
            }).catch(err => {
                console.log(err)
            })
        },
        toSearch(value) {
            this.showPhotoPage = false;
            this.isHaveData = false;
            this.searchObj = JSON.parse(JSON.stringify(value));
            this.searchContent = this.searchObj.content;
            this.selectedType = this.searchObj.searchType;
            // this.searchFieldObj.searchType = this.selectedType;
            // this.searchFieldObj.content = this.searchObj.content
            this.searchDeptObj.searchType = this.selectedType;
            this.searchDeptObj.content = this.searchObj.content
            this.getData();
            this.addSearchContentLog(this.searchContent);
        },
        onSearch(value) {
            if(!value){
                this.$message.error('请输入内容！')
                return;
            }
            this.searchContent = value;
            console.log(this.searchContent);
            this.$emit('changeObj', this.selectedType, value);
            this.currentPageNo = 1
            this.isHaveData = false;
            this.searchObj.current = 1
            this.searchObj.pageNo = 1
            this.searchObj.pageSize = 10
            this.searchObj.searchType = this.selectedType;
            this.searchObj.content = value
            this.searchObj.fieldNames = []
            this.searchObj.orgNames = []
            this.searchTalentInfoObj = {
                current: 1,
                pageNo: 1,
                pageSize: 10
            };
            this.searchTalentInfoObj.fields = []
            // this.searchFieldObj.searchType = this.selectedType;
            // this.searchFieldObj.content = value
            this.searchDeptObj.searchType = this.selectedType;
            this.searchDeptObj.content = value
            this.talentFruitList = {
                records: []
            };
            this.researchFields = [];
            this.cooperationDepts = [];
            this.showFields = [];
            this.showDepts = [];
            this.fieldsNum = 10;
            this.deptsNum = 10;
            // 重新赋值
            if(this.showAllFlag){
                this.talentCurrentPageNo = 1
                this.searchTalentInfoObj.current = 1
                this.searchTalentInfoObj.pageNo = 1
                this.searchTalentInfoObj.pageSize = 10
                this.searchTalentInfoObj.searchType = this.selectedType;
                this.searchTalentInfoObj.content = value
                this.searchTalentInfoObj.fields = []
                this.searchTalentInfoObj.orgNames = []
                this.getAllTalentInfo();
            }else{
                // this.searchObj.orgUserId = null;
                // this.searchObj.searchType = this.selectedType;
                // this.searchObj.content = value;
                this.getData();
            }
            this.addSearchContentLog(value);
        },
        getData(){
            this.searchObj.orgUserId = null;
            this.selectedAuthorName = "";
            this.getTalentData(true);
            // this.getTalentDeptData();
        },
        getTalentData(flag){
            let url = "/ndTalent/fruit/getTalentData";

            this.loading = true;
            this.isHaveDataTalent = false;

            this.selectedOrgUserId = "";
            this.selectedAuthorName = "";
            postAction(url, this.searchObj).then(res => {
                if (res.data.success) {
                    this.talentInfoList = res.data.result
                    this.loading = false;
                    this.isHaveDataTalent = true;
                    let resArr = this.talentInfoList.records;
                    if(resArr.length > 0){
                        for(let n in resArr){
                            if(resArr[n].company){
                                resArr[n].company = removeDuplicates(resArr[n].company, ",");
                            }
                        }
                        this.selectedOrgUserId = resArr[0].authorId;
                        this.selectedAuthorName = resArr[0].authorName;
                        // this.getTalentFieldData(this.selectedOrgUserId);
                        if(flag){
                            this.getTalentFieldDataByResult(res.data.result);
                        }
                        this.getTalentFruitList();
                    }else{
                        // this.getOtherTalentData();
                    }
                }
            }).catch(err => {
                console.log(err)
                this.loading = false;
            })
        },
        getOtherTalentData(){
            let url = "/ndTalent/fruit/getTalentData";
            postAction(url, this.searchObj).then(res => {
                if (res.data.success) {
                    this.otherTalentInfoList = res.data.result
                    this.otherloading = false;
                    this.isHaveOtherDataTalent = true;
                    let resArr = this.otherTalentInfoList.records;
                    if(resArr.length > 0){
                        for(let n in resArr){
                            if(resArr[n].company){
                                resArr[n].company = removeDuplicates(resArr[n].company, ",");
                            }
                        }
                    }else{
                        this.talentFruitList = {
                            records: []
                        }
                    }
                }
            }).catch(err => {
                console.log(err)
                this.otherloading = false;
            })
        },
        getTalentFieldDataByResult(result){
            this.fieldNamesCount = {};
            this.isHaveDataFields = false;
            this.isHaveDataFields = true;

          // 初始化字段计数对象
          result.records.forEach(record => {
            record.fieldNames.split(',').forEach(fieldName => {
              fieldName = fieldName.trim();
              this.incrementCount(fieldName);
            });
          });
          this.showFields = Object.keys(this.fieldNamesCount)
              .filter(fieldName => fieldName != '' && fieldName != null)
              .map(fieldName => ({ name: fieldName, count: this.fieldNamesCount[fieldName] }));
        },
        incrementCount(fieldName) {
          if (this.fieldNamesCount[fieldName]) {
            this.fieldNamesCount[fieldName] += 1;
          } else {
            this.fieldNamesCount[fieldName] = 1;
          }
        },
        getTalentFieldData(authorId){
            let url = "/ndTalent/fruit/getTalentFieldData";
            this.searchFieldObj.orgUserId = authorId;
            this.searchFieldObj.content = this.searchContent;
          this.searchTalentInfoObj.searchType = this.selectedType;
            this.isHaveDataFields = false;
            postAction(url, this.searchFieldObj).then(res => {
                if (res.data.success) {
                    this.isHaveDataFields = true;
                    this.researchFields = res.data.result;
                    this.researchFieldsTotal = res.data.result.length;
                    this.showFields = this.researchFields;
                    // this.searchObj.fields = this.researchFields.map(item => {
                    //     return item.name
                    // });
                }
            }).catch(err => {
                console.log(err)
                this.isHaveDataFields = true;
            })
        },
        getTalentDeptData(){
            let url = "/ndTalent/fruit/getTalentDeptData";

            this.isHaveDataDepts = false;
            postAction(url, this.searchDeptObj).then(res => {
                if (res.data.success) {
                    this.isHaveDataDepts = true;
                    this.cooperationDepts = res.data.result.records;
                    this.cooperationDeptsTotal = res.data.result.total;
                    this.showDepts = this.cooperationDepts;
                    // this.searchObj.orgNames = this.cooperationDepts.map(item=>{return item.name});
                }
            }).catch(err => {
                console.log(err)
                this.isHaveDataDepts = true;
            })
        },
        showMoreFieldsData(){
            this.fieldsNum += 10;
            this.showFields = this.researchFields.slice(0, Math.min(this.researchFields.length, this.fieldsNum));
        },
        showMoreDeptsData(){
            this.deptsNum += 10;
            this.showDepts = this.cooperationDepts.slice(0, Math.min(this.cooperationDepts.length, this.deptsNum));
        },
        changFruitData(authorId, authorName, isContainField){
            this.selectedOrgUserId = authorId;
            this.selectedAuthorName = authorName;
            this.isContainField = isContainField;
            // this.getTalentFieldData(this.selectedOrgUserId);
            this.currentPageNo = 1;
            this.searchTalentFruitObj = {
                current: 1,
                pageNo: 1,
                pageSize: 10
            };
            this.getTalentFruitList();
        },
        getTalentFruitList(){
            let fruitUrl = "/ndTalent/fruit/list";
            this.searchTalentFruitObj.orgUserId = this.selectedOrgUserId;
            this.searchTalentFruitObj.authorName = this.selectedAuthorName;
            this.searchTalentFruitObj.content = this.searchContent;
            this.searchTalentFruitObj.searchType = this.selectedType;
            this.searchTalentFruitObj.pubStartDate = this.searchObj.pubStartDate;
            this.searchTalentFruitObj.pubEndDate = this.searchObj.pubEndDate;
            this.isHaveFruitData = false;
            postAction(fruitUrl, this.searchTalentFruitObj).then(res => {
                if (res.data.success) {
                    this.talentFruitList = res.data.result
                    this.isHaveFruitData = true;
                }
            }).catch(err => {
                console.log(err)
            })
        },
        dataChange(date, dateString) {
            this.rangeValue = date;
            this.searchObj.pubStartDate = dateString[0];
            this.searchObj.pubEndDate = dateString[1];
            this.searchObj.current = 1;
            this.searchObj.pageNo = 1;
            this.currentPageNo = 1;
            this.getData();
        },
        setDateType(value){
            this.rangeValue = [];
            this.searchObj.pubStartDate = "";
            this.searchObj.pubEndDate = getCurrentDate();
            if(value === this.selectedBtnType){
                this.selectedBtnType = "";
            }else{
                this.selectedBtnType = value;

                this.searchObj.pubStartDate = getMonthFirstDay(getBeforeMonth(value * 12));
            }
            this.getData();
        },
        onChangeField(checkedValues) {
            this.searchObj.fieldNames = checkedValues;
            this.searchObj.orgUserId = null;
            // this.searchTalentFruitObj.gwFields = checkedValues;
            this.searchObj.gwFields = checkedValues;
            this.getTalentData(false);
            this.getTalentFruitList();
        },
        onChangeDept(checkedValues) {
            this.searchObj.orgNames = checkedValues;
            this.searchObj.orgUserId = null;
            this.getTalentData(true);
        },
        onChangePage(event) {
            // 重新赋值
            this.currentPageNo = event
            this.searchTalentFruitObj.current = event
            this.searchTalentFruitObj.pageNo = event
            this.getTalentFruitList(this.searchTalentFruitObj);
            window.scrollTo({
                top: 0,
                behavior: 'smooth', // 使用平滑滚动
            });
        },
        changeNew(){
            if(this.talentInfoList.total <= 10){
                this.$message.error('当前专家已全部展现，无更多数据！')
                return;
            }
            if((this.searchObj.pageNo+1) * 10 > this.talentInfoList.total){
                this.currentPageNo = 1;
                this.searchObj.current = 1;
                this.searchObj.pageNo = 1;
            }else{
                this.refreshLoading = true;
                this.currentPageNo = this.currentPageNo + 1;
                this.searchObj.pageNo = this.searchObj.pageNo + 1;
                this.searchObj.current = this.searchObj.current + 1;
                this.getTalentData();
                this.refreshLoading = false;
            }
        },
        advancedSearch(){
            if(!this.showAllFlag){
                this.showAllFlag = true;
                this.searchTalentInfoObj.content = this.searchContent;
                this.searchTalentInfoObj.searchType = this.selectedType;
                this.searchTalentInfoObj.pageSize = 12;
                this.searchTalentInfoObj.fields = []
                this.searchTalentInfoObj.orgNames = []
                this.getAllTalentInfo();
            }else{
                this.showAllFlag = false;
            }
        },
        showAllTalentInfo(type) {
            this.showAllFlag = true;
            this.searchTalentInfoObj.content = this.searchContent;
            this.searchTalentInfoObj.searchType = this.selectedType;
            this.searchTalentInfoObj.pageSize = 12;
            this.searchTalentInfoObj.fields = []
            this.searchTalentInfoObj.orgNames = []
            if(type == 1){
                this.getAllTalentInfo();
            }else if(type == 2){
                this.getOtherAllTalentInfo();
            }
        },
        getAllTalentInfo(){
            this.isHaveTalentInfoData = false;
            let url = "/ndTalent/fruit/getTalentData";
            this.searchTalentInfoObj.pageSize = this.showAllFlag ? 12 : 10;
            postAction(url, this.searchTalentInfoObj).then(res => {
                this.isHaveTalentInfoData = true;
                if (res.data.success) {
                    this.talentAllInfoList = res.data.result
                }
            }).catch(err => {
                console.log(err)
                this.loading = false;
            })
        },
        getOtherAllTalentInfo(){
            this.isHaveTalentInfoData = false;
            let url = "/ndTalent/fruit/getTalentData";
            postAction(url, this.searchTalentInfoObj).then(res => {
                this.isHaveTalentInfoData = true;
                if (res.data.success) {
                    this.talentAllInfoList = res.data.result
                }
            }).catch(err => {
                console.log(err)
                this.loading = false;
            })
        },
        changeTalentInfo(item) {
            if(this.selectedPinYin == item){
                item = "";
            }
            this.selectedPinYin = item;
            this.searchTalentInfoObj.pinyin = item;
            this.searchTalentInfoObj.content = this.searchContent;
            this.getAllTalentInfo();
        },
        onChangeGwField(checkedValues) {
            console.log('checked = ', checkedValues);
            this.fieldCheckedList = checkedValues;
            this.searchTalentInfoObj.gwFields = checkedValues;
            this.searchTalentInfoObj.content = this.searchContent;
            this.getAllTalentInfo();
        },
        onChangeGwFruitType(checkedValues) {
            console.log('checked = ', checkedValues);
            this.fruitTypeCheckedList = checkedValues;
            this.searchTalentInfoObj.fruitTypes = checkedValues;
            this.searchTalentInfoObj.content = this.searchContent;
            this.getAllTalentInfo();
        },
        onChangeTalentPage(event) {
            // 重新赋值
            this.talentCurrentPageNo = event
            this.searchTalentInfoObj.current = event
            this.searchTalentInfoObj.pageNo = event
            this.getAllTalentInfo();
        },
    }
}
</script>
<style scoped>

.header_search {
    /*width: 800px;*/
    margin: auto;
}
/deep/ .header_search .ant-input-group .ant-input{
    height: 50px !important;
    line-height: 50px !important;
}
/deep/ .header_search .ant-input-group .ant-input-affix-wrapper{
    font-size: 20px;
}
/deep/ .header_search .ant-card-small > .ant-card-head{
    border-bottom: 1px solid #038181 !important;
}
/deep/ .header_search .ant-input-group .ant-input-group-addon{
    border-radius: 50px 0 0 50px !important;
}
/deep/ .header_search .ant-input-group .ant-input{
    border-radius:  0 50px 50px 0 !important;
}
/deep/ .header_search .ant-input-clear-icon{
    padding-right: 100px !important;
}
/deep/ .header_search .ant-input-affix-wrapper .ant-input{
  border-radius: 50px;
  height: 50px !important;
  padding-left: 20px;
}
/deep/ .header_search .ant-input-search-icon{
  font-size: 25px;
}
.dateBtn{
    height: 30px;
    font-size: 16px;
}
.cardTit{
    font-size: 18px;
    font-weight: bold;
}
.ft{
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
}
.pagCs{
    padding: 20px 0;
    text-align: center;
}
.bordc{
    border: 5px solid #9dfb76;
}
.spin-content {
    border: 1px solid #91d5ff;
    background-color: #e6f7ff;
    padding: 30px;
}
.bigd{
    font-size: 25px;
    color: rgba(0, 128, 128, 1);
}
.def{
    font-size: 18px;
    color: rgba(253, 128, 36, 1);
}

#components-back-top-demo-custom .ant-back-top {
    bottom: 100px;
}
#components-back-top-demo-custom .ant-back-top-inner {
    height: 40px;
    width: 40px;
    line-height: 40px;
    border-radius: 4px;
    background-color: rgba(0, 128, 128, 1);
    color: #fff;
    text-align: center;
    font-size: 20px;
}
</style>